﻿using NUnit.Framework;
using System.Collections.Generic;
using System;
using static WordBookmarkReplacer;

namespace TestProject1
{
    public class Tests
    {
        [SetUp]
        public void Setup()
        {
        }

        [Test]
        public void Test1()
        {
            var bookData = new WordBookmarkReplacer.BookData()
            {
                marks = new Dictionary<string, string>
                {
                    ["CustomerName"] = "张三",
                    ["ContractNo"] = "HT-2025-001",
                    ["SignDate"] = "2025-10-29",
                    ["faaa"] = "2025-10-29aaa",
                    ["fbbb"] = "2025-10-29bbb",
                    ["fccc"] = "2025-10-29ccc",
                    ["fddd"] = "2025-10-29ddd",
                },
                placeholders = new Dictionary<string, string>
                {
                    ["[[fname]]"] = "name-name",
                    ["[[fnumber]]"] = "number-number",
                    ["[[fcol1]]"] = "fcol1",
                    ["[[fcol2]]"] = "fcol2",
                    ["[[fcol3]]"] = "fcol3",
                },
                tables = new Dictionary<int, List<List<string>>>
                {
                    [0] = new List<List<string>> // 表格索引 0
                        {
                            new List<string>{ "1", "苹果", "10", "15元" },
                            new List<string>{ "2", "香蕉", "20", "25元" },
                            new List<string>{ "3", "橘子", "5", "8元" }
                        }
                },
                images = new List<WordBookmarkReplacer.ImageData>
                    {
                        new WordBookmarkReplacer.ImageData
                        {
                            BookmarkName = "Signature",
                            ImagePath = @"D:\temp.png",
                            Width = 150,
                            Height = 80
                        },
                        new WordBookmarkReplacer.ImageData
                        {
                            BookmarkName = "CompanyLogo",
                            ImagePath = @"D:\temp.png",
                            Width = 100,
                            Height = 60
                        },
                        new WordBookmarkReplacer.ImageData
                        {
                            BookmarkName = "img1",
                            ImagePath = @"D:\temp.png",
                            Width = 100,
                            Height = 60
                        }
                    }
            };

            string templatePath = @"D:\temp.docx";
            string outputPath = @"D:\temp-out.docx";

            WordBookmarkReplacer.GenerateWord(templatePath, outputPath, bookData);
            Console.WriteLine("✅ Word 模板生成完成: " + outputPath);
        }

        [Test]
        public void Test2()
        {
            var bookData = new WordBookmarkReplacer.BookData()
            {
                //marks = new Dictionary<string, string>
                //{
                //    ["CustomerName"] = "张三",
                //    ["ContractNo"] = "HT-2025-001",
                //    ["SignDate"] = "2025-10-29",
                //    ["faaa"] = "2025-10-29aaa",
                //    ["fbbb"] = "2025-10-29bbb",
                //    ["fccc"] = "2025-10-29ccc",
                //    ["fddd"] = "2025-10-29ddd",
                //},
                placeholders = new Dictionary<string, string>
                {
                    ["[[fzhengshubianhao]]"] = "name-name",
                    ["[[fnumber]]"] = "number-number",
                  },
                tables = new Dictionary<int, List<List<string>>>
                {
                    [2] = new List<List<string>> // 表格索引 0
                        {
                            new List<string>{ "1", "苹果", "10", "15元" },
                            new List<string>{ "2", "香蕉", "20", "25元" },
                            new List<string>{ "3", "橘子", "5", "8元" }
                        }
                },
                images = new List<WordBookmarkReplacer.ImageData>
                    {
                        new WordBookmarkReplacer.ImageData
                        {
                            BookmarkName = "img1",
                            ImagePath = @"D:\temp.png",
                            Width = 100,
                            Height = 60
                        },
                        new WordBookmarkReplacer.ImageData
                        {
                            BookmarkName = "img2",
                            ImagePath = @"D:\temp.png",
                            Width = 100,
                            Height = 60
                        }
                    }
            };

            string templatePath = @"D:\temp2.docx";
            string outputPath = @"D:\temp-out.docx";

            WordBookmarkReplacer.GenerateWord(templatePath, outputPath, bookData);
            Console.WriteLine("✅ Word 模板生成完成: " + outputPath);
        }

    }
}